#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define HashLength 1<<16

int HashString(char *p)
{
	char *s = p;
	int hashValue=0;
	while(*s!='\0')
	{
		hashValue += ((int)(*s))*((int)(*s))>>(s-p);
		if(hashValue>HashLength)
			hashValue = hashValue%HashLength;
		s++;
	}
	return hashValue;
}

int testmain(int argc,char **argv)
{

	char *s = "hello world";
	char *s1 = "define";
	char *s2 = "if";
	char *s3 = "ifndef";
	printf("%d\n",HashString(s));
	printf("%d\n",HashString(s1));
	//  printf("%d\n",HashString(s2));
	//  printf("%d\n",HashString(s3));
	return 0;
}
